package com.ruoyi.jl.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.jl.domain.Robot;
import com.ruoyi.jl.mapper.RobotMapper;
import com.ruoyi.jl.service.IRobotService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 机器人控制 服务层实现
 * 
 * @author wh
 * @date 2019-04-29
 */
@Slf4j
@Service
public class RobotServiceImpl extends ServiceImpl<RobotMapper, Robot> implements IRobotService {

    @Override
    public List<Robot> list(Robot robot){
        LambdaQueryWrapper<Robot> wrapper = new LambdaQueryWrapper<>();
        if(robot != null){
            if(StringUtils.isNotEmpty(robot.getId())){
                wrapper.eq(Robot::getId, robot.getId());
            }
            if(StringUtils.isNotEmpty(robot.getGameName())){
                wrapper.like(Robot::getGameName, robot.getGameName());
            }
            if(StringUtils.isNotEmpty(robot.getRobotNum())){
                wrapper.eq(Robot::getRobotNum, robot.getRobotNum());
            }
            if(StringUtils.isNotEmpty(robot.getTimeRange())){
                wrapper.eq(Robot::getTimeRange, robot.getTimeRange());
            }
            if(StringUtils.isNotEmpty(robot.getWinProbability())){
                wrapper.eq(Robot::getWinProbability, robot.getWinProbability());
            }
            if(StringUtils.isNotEmpty(robot.getWinVariance())){
                wrapper.eq(Robot::getWinVariance, robot.getWinVariance());
            }
        }
        return baseMapper.selectList(wrapper);
    }
}
